package SpringCloudBase;

import SpringCloudBase.config.ExcluConfig;
import SpringCloudBase.config.SpringCloudRibbonConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.web.client.RestTemplate;
/**
 * Hello world!
 *
 */
@SpringBootApplication
@EnableEurekaClient
@RibbonClient(name = "PROVIDER-USER",configuration = SpringCloudRibbonConfig.class) //启用并对PROVIDER-USER进行负载均衡
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,value = ExcluConfig.class)})
public class SpringCLoudRibbonApplication
{
    public static void main( String[] args )
    {
        System.err.println( "请稍等-正在加载Ribbon项目" );
        SpringApplication.run(SpringCLoudRibbonApplication.class);
    }

    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
}
